import 'package:flutter/material.dart';
import 'package:jieqifang/global.dart';
import 'package:jieqifang/item.dart';

class IndexPage extends StatefulWidget {
  IndexPage({Key key}) : super(key: key);

  @override
  _IndexPageState createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  @override
  void initState() {
    super.initState();
  }

  List<Widget> renderItem(items) {
    List<Widget> list = [];
    for (var i = 0; i < items.length; i++) {
      var item = items[i];
      list.add(Item(data: item, index: i));
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '节气坊',
          style: TextStyle(
            color: Global.backgroundColor,
            fontSize: 19,
            fontFamily: 'QiuHongKai',
            fontWeight: FontWeight.bold,
          ),
        ),
        brightness: Brightness.dark,
        backgroundColor: Global.primaryColor,
        elevation: 20,
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        child: SingleChildScrollView(
          child: Column(
            children: [Column(children: renderItem(Global.jieqiList))],
          ),
        ),
      ),
    );
  }
}
